package com.mriassl.consumer.user.command;

import java.util.List;

import com.mriassl.consumer.user.domain.User;
import com.mriassl.consumer.user.service.UserService;
import com.netflix.hystrix.HystrixCommand;
import com.netflix.hystrix.HystrixCommandGroupKey;
import com.netflix.hystrix.HystrixCommandKey;

public class UserBatchCommand extends HystrixCommand<List<User>> {

	private UserService userService;
	private List<String> userIds;

	public UserBatchCommand(UserService userService, List<String> userIds) {
		super(Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("userServiceCommand"))
				.andCommandKey(HystrixCommandKey.Factory.asKey("userBatchCommand")));
		this.userService = userService;
		this.userIds = userIds;
	}

	@Override
	protected List<User> run() throws Exception {
		return userService.findByIds(userIds);
	}

}
